accessibility
Macromedia Logo Upper Navigation Bar
 Help
Lower Navigation Bar
ProductsSupportDesigner DeveloperDownloadsStoreInternationalSite MapCompany
Home > Products > Flash > Support > TechNote Index
Macromedia Flash Support Center - TechNotes

Sending email from Flash 5

Product: Flash
Platform: All
Versions: 5.0
ID: 15695
How useful was this document?
less more

1

2

3

4

5

How can the document be improved? (300 characters or less - you will not receive a reply.)

Introduction
This TechNote describes a method for sending e-mail from a Flash 5 movie. For steps on sending email from a Flash 4 movie see How to create a button that will send e-mail messages (Technote 14072).

Note: This method requires that the Web browser in which the movie is running be configured to send e-mail. Most, but not all, browsers support this feature. Also, some decide to disable their browser's e-mail feature for security reasons. If sending e-mail is an optional movie feature then this method provides a quick and easy way to accomplish that. However, if the ability to send e-mail is a requirement for a Flash movie then a more robust and reliable technique is to use a CGI form mailer or similar server-side application. For more information on this technique refer to Using Flash with a CGI form mailer (TechNote 14158).

Launch an e-mail composition window from a Flash button
A button in Flash can have an action assigned that will launch an e-mail composition window with an address already specified.

Assign the Get URL action to the button
The Get URL action can be used to link to an e-mail address. By adding additional parameters, the resulting e-mail browser window can be configured with pre-written text in the subject line or body of the message. Browser support for e-mail parameters varies. If unsupported parameters are encountered, the browser will ignore them.

To create an email link for a button, follow the steps below:
1

This technique can be applied to any button. You may design your own button, or use an existing button from Window> Common Libraries> Buttons. Place an instance of the button onstage.

2

Select the button and open the Actions Panel. Depending on preferences, at this point the Actions Panel may be in Expert mode. The basic technique in this technote can be applied in Normal mode. However, for the more advanced techniques below it will be easier to use Expert mode. Click the popup and choose Normal mode.

 

For more detail on Expert and Normal mode see Getting Started with ActionScript on the Macromedia Flash Support Center.

3

In the left pane, expand the Basic Actions. Double click "Get URL" to add the basic action to the button instance.

 
4

In the "URL" field, add a URL beginning with 'mailto:' followed by the email address that the mail should be sent to:

 
5

The "Window" field should be left blank, and the "Variables" field remains "Don't Send"

This is the simplest method of sending a message to the system to launch it's default email application and create a new mail. However, the only that will be filled in at this point is the receivers' address.

Filling out the Subject, Body and other headers
Flash 5 can also use input text fields and variables to pre-fill the common headers in the email, such as "Subject", "Body" and "CC", for example. There are several methods for doing so.

Using search parameters:
1

Use a question mark following the e-mail address, then a parameter followed by an equal sign to set the text. Additional parameters can be added by typing an ampersand between them. The entire customized string of parameters can be entered into the URL field in the URL field to set the fields of the e-mail composition window as desired. For example:

 
2

If the URL field is not long enough to enter all of the desired text, switch the Actions Panel to Expert Mode and enter the text directly in the action

Using search parameters with input text fields:

1

The second method sets the e-mail headers using search parameters also. But this method takes the text that should be placed in the headers from the contents of input text fields entered by the viewer, similar to an HTML form.

The following is a working example of this technique. Enter appropriate responses in the fields, then click the "mail" button to e-mail the results:

   
2

Each field is created as an Input Text Field. Each is then assigned the variable name that matches the name of the email header it correspon ds to. For example, the variable name of the "recipient" field inside Flash is actually "recipient".

3

The button action used to pick up the text held in the variables is:

on (release){
getURL ("mailto:" +recipient+ "?cc=" + cc + "&subject=" + subject + "&body=" +body)
}

Pay attention to the order of the strings and the variables. The '+' is the Flash 5 concatentation operator. When the action is run it concatenates the items withing double quotes with the contents of the input text fields. The final string sent to the email system looks like:
"mailto:joe@server.com?cc=webmaster@yoursite.com&subject=sendmail&body=some text here"

The email application then strips this text into the appropriate headers in the final mail.



Last updated: January 22, 2003
Keywords: email, button, getURL, cgi, mail, form
Created: July 26, 2001
©1995-2003 Macromedia, Inc. All rights reserved.
Use of this website signifies your agreement to the Terms of Use.
Privacy | Site Map
| Contact us | Accessibility | Report Piracy